<?php
class heart extends CI_Controller {
    public function __construct()
    {
        parent::__construct();
        $this->load->model('heartmanager');
        $this->load->helper('url_helper');
    }
	public function GetIP(){ 
        $ip= $_SERVER["REMOTE_ADDR"];
        $data=array('ip'=>$ip,'timestamp'=>time());
        echo json_encode($data); 
	}
    public function getByRouter(){
		parse_str($_SERVER['QUERY_STRING'], $_GET);
		$user=$_REQUEST["user"];
		$ip=$_REQUEST["ip"];
        $data=$this->heartmanager->router($user,$ip);
		echo json_encode($data);
    }
    public function getByShell(){
		parse_str($_SERVER['QUERY_STRING'], $_GET);
		$user=$_REQUEST["user"];
        $ip= $_SERVER["REMOTE_ADDR"];
        $data=$this->heartmanager->shell($user,$ip);
		echo $data;
    }
    public function getByDeskApp(){
		parse_str($_SERVER['QUERY_STRING'], $_GET);
		$user=$_REQUEST["user"];
		$ip=$_REQUEST["ip"];
        $data=$this->heartmanager->desk_app($user,$ip);
		echo json_encode($data);
    }
	
	public function getByApp(){
		parse_str($_SERVER['QUERY_STRING'], $_GET);
		$user=$_POST["user"];
		$ip=$_REQUEST["ip"];
		$time=$_REQUEST["timestamp"];
		$appModel=$_REQUEST["appModel"];
		$sign=$_REQUEST["sign"];
		$mac=$_REQUEST["mac"];
		$data=$this->heartmanager->app($user,$ip,$time,$appModel,$sign,$mac);
		//$data=array("status"=>201,"message"=>"good".time());
		echo json_encode($data);
	}
}